package com.example.demo.service.imp;

import java.text.SimpleDateFormat;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.demo.dto.OrderInfDto;
import com.example.demo.dto.OrderMangeDto;
import com.example.demo.dto.UserMangeDto;
import com.example.demo.dto.VipMangeDto;
import com.example.demo.mapper.ManageMapper;
import com.example.demo.mapper.TestMapper;
import com.example.demo.service.ManageService;
import com.example.demo.service.TestService;

@Service
@Transactional
public class ManageServiceImp implements ManageService{
	@Resource
	private ManageMapper manageMapper;

	@Override
	public List<OrderMangeDto> getAllOrder() {
		return manageMapper.getOrder();
		
	}

	@Override
	public List<UserMangeDto> getAllUser() {
		return manageMapper.getUser();
	}

	@Override
	public String deleteOrder(int id) {
		String result = "删除失败";
		int re=manageMapper.delOrder(id);
		if(re>0) {
			result="删除成功";
		}
		return result;
	}

	@Override
	public String deleteUser(int id) {
		String result = "删除失败";
		int re=manageMapper.delUser(id);
		if(re>0) {
			result="删除成功";
		}
		return result;
	}

	@Override
	public List<VipMangeDto> getAllVip() {
		return manageMapper.getVip();
	}

	@Override
	public String deleteVip(int vid) {
		String result = "删除失败";
		int re=manageMapper.delVip(vid);
		if(re>0) {
			result="删除成功";
		}
		return result;
	}

	@Override
	public String toChangeVip(int vid, String vlevel, double vdiscount) {
		String result = "更新失败";
		int re=manageMapper.changeVip(vid,vlevel,vdiscount);
		if(re>0) {
			result="更新成功";
		}
		return result;
	}

	@Override
	public String insertVip(String vlevel, double vdiscount) {
		String result = "新增失败";
		int re=manageMapper.inVip(vlevel,vdiscount);
		if(re>0) {
			result="新增成功";
		}
		return result;
	}

	@Override
	public String feedback(String title, String text) {
		String result = "新增失败";
		int re=manageMapper.feedbackInf(title,text);
		if(re>0) {
			result="新增成功";
		}
		return result;
	}

	@Override
	public OrderInfDto getOrderInf(int oid) {
		OrderInfDto o=manageMapper.orderInf(oid);
		return o;
	}


	

	

	

}
